a = input('Введите скобку')
stack = []
f = 1

if a[0] in ')]}>':
    f = 0

for i in a:
    if i in '([{<':
         stack.append(i)
         last = stack[-1]
         if ((i == ')' and last == '(')
         or (i == '}' and last == '{')
         or (i == '>' and last == '<')
             or (i == ']' and last == '[')
         ):
             stack.pop()
         else:
             break

if len(stack) == 0 and f == 1:
    print(True)
else:
    print(False)